<div class="content-wrapper">
    <?php
    $form = $this->form;
    $form->prepare();

    $form->get('memberAccount')->setAttributes([
        'placeholder' => $this->translate('登录账号')
    ]);
    if(isset($this->member) && $this->member->getMemberId()) {
        $form->get('memberAccount')->setAttributes([
            'readonly' => true
        ]);
    }

    $form->get('memberName')->setAttributes([
        'placeholder' => $this->translate('姓名')
    ]);

    $form->get('memberPhone')->setAttributes([
        'placeholder' => $this->translate('联系电话')
    ]);

    if(!isset($this->member)) {
        $form->get('memberPassword')->setAttributes([
            'placeholder' => $this->translate('登录密码')
        ]);
        $form->get('memberComPassword')->setAttributes([
            'placeholder' => $this->translate('确认密码')
        ]);
    }
    ?>
    <?php echo $this->form()->openTag($form); ?>
    <section class="content-header">
        <?php echo $this->partial('layout/breadcrumb'); ?>

        <h1 class="pull-right" id="dbshop-menu-top">
            <a href="<?php echo $this->url('self-location', ['action' => 'memberList']);?>" class="btn btn-default btn-sm"><i class="fa fa-arrow-left"></i> <?php echo $this->translate('返回核销人员列表'); ?></a>
            <button type="submit" class="btn btn-primary btn-sm"><i class="fa fa-check"></i> <?php echo $this->translate('保存核销人员信息'); ?></button>
            <?php echo $this->HelpUrl('locationMember'); ?>
        </h1>
    </section>

    <section class="content">

        <div class="row">
            <div class="col-md-12">
                <div class="box box-primary">
                    <div class="box-header with-border">
                        <h3 class="box-title"><?php echo (isset($this->member) ? $this->translate('编辑核销人员') : $this->translate('添加核销人员')); ?></h3>
                    </div>

                    <div class="box-body">
                        <div class="form-group">
                            <label class="col-sm-2 control-label"><?php echo $this->translate('自提点'); ?><span class="must_add_value">*</span></label>
                            <div class="col-sm-3">
                                <?php echo $this->formElement($form->get('locationId')); ?>
                                <?php echo $this->formElementErrors($form->get('locationId'), ['class'=>'error-message']); ?>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-2 control-label"><?php echo $this->translate('登录账号'); ?><span class="must_add_value">*</span></label>
                            <div class="col-sm-3">
                                <?php echo $this->formElement($form->get('memberAccount')); ?>
                                <?php echo $this->formElementErrors($form->get('memberAccount'), ['class'=>'error-message']); ?>
                            </div>
                        </div>
                        <?php if(!isset($this->member)) { ?>
                            <div class="form-group">
                                <label class="col-sm-2 control-label"><?php echo $this->translate('登录密码'); ?><span class="must_add_value">*</span></label>
                                <div class="col-sm-3">
                                    <?php echo $this->formElement($form->get('memberPassword')); ?>
                                    <?php echo $this->formElementErrors($form->get('memberPassword'), ['class'=>'error-message']); ?>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label"><?php echo $this->translate('确认密码'); ?><span class="must_add_value">*</span></label>
                                <div class="col-sm-3">
                                    <?php echo $this->formElement($form->get('memberComPassword')); ?>
                                    <?php echo $this->formElementErrors($form->get('memberComPassword'), ['class'=>'error-message']); ?>
                                </div>
                            </div>
                        <?php } ?>
                        <div class="form-group">
                            <label class="col-sm-2 control-label"><?php echo $this->translate('真实姓名'); ?><span class="must_add_value">*</span></label>
                            <div class="col-sm-3">
                                <?php echo $this->formElement($form->get('memberName')); ?>
                                <?php echo $this->formElementErrors($form->get('memberName'), ['class'=>'error-message']); ?>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label"><?php echo $this->translate('联系电话'); ?><span class="must_add_value">*</span></label>
                            <div class="col-sm-3">
                                <?php echo $this->formElement($form->get('memberPhone')); ?>
                                <?php echo $this->formElementErrors($form->get('memberPhone'), ['class'=>'error-message']); ?>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-2 control-label"><?php echo $this->translate('状态'); ?></label>
                            <div class="col-sm-6">
                                <div class="checkbox">
                                    <label>
                                        <?php echo $this->formElement($form->get('memberState')); ?> <?php echo $this->translate('启用'); ?>
                                        <?php echo $this->formElementErrors($form->get('memberState'), ['class'=>'error-message']); ?>
                                    </label>
                                </div>
                            </div>
                        </div>
                    </div>

                </div>
            </div>
        </div>

    </section>
    <?php echo $this->form()->closeTag(); ?>
</div>
<script type="text/javascript">
    $(document).ready(function() {
        $("#<?php echo $form->getName(); ?>").validate({
            rules: {
                locationId: {
                    required: true,
                    min:1
                },
                memberName: {
                    required: true
                },
                memberPhone: {
                    required: true
                }
                <?php if(!isset($this->member)) { ?>
                ,
                memberAccount: {
                    required: true
                },
                memberPassword: {
                    required: true
                },
                memberComPassword: {
                    required: true,
                    equalTo: "#memberPassword"
                }
                <?php } ?>
            },
            messages: {
                locationId: {
                    required: "<?php echo $this->translate('请选择自提点'); ?>",
                    min: "<?php echo $this->translate('请选择自提点'); ?>"
                },
                memberName: {
                    required: "<?php echo $this->translate('请输入真实姓名'); ?>"
                },
                memberPhone: {
                    required: "<?php echo $this->translate('请输入联系电话'); ?>"
                }
                <?php if(!isset($this->member)) { ?>
                ,
                memberAccount: {
                    required: "<?php echo $this->translate('请输入登录账号'); ?>"
                },
                memberPassword: {
                    required: "<?php echo $this->translate('请输入登录密码'); ?>"
                },
                memberComPassword: {
                    required: "<?php echo $this->translate('请输入确认密码'); ?>",
                    equalTo: "<?php echo $this->translate('两次输入的密码不一致'); ?>"
                }
                <?php } ?>
            }
        });
    });
</script>